<template>
    <section class="p-18">
        <a-table style="min-height: 220px;" :columns="columns" :data-source="tableData"  :pagination="false">
            <template #time="time">
                {{ time.startTime +"~" + time.endTime }}
            </template>
            <template #isEnabled="isEnabled">
                {{ isEnabled.isEnabled?"有效":"无效" }}
            </template>
        </a-table>

        <div class="flex justify-end mt-20 items-center">
                <div class="pr-20">共{{ rowCount }}条记录，第{{ pageNum }}/{{ Math.ceil(rowCount / rowsNum) }} 页</div>
                <a-pagination
                    v-model="pageNum"
                    show-size-changer
                    show-quick-jumper
                    :page-size.sync="rowsNum"
                    :total="rowCount"
                    @showSizeChange="sizeChange"
                    @change="pageChange"
                >
                </a-pagination>
            </div>
        
    </section>
    
  </template>
  
  <script>
  import { vacationList } from '@/api/store/index'
  export default {
    components: {},
    props: {
      data: {
        type: Object,
        default: () => ({}),
      },
      storeId2: {
        type: Number,
      },
    },
    data() {
      return {
        columns: [
                {title: '休息日', align: 'center', scopedSlots: {customRender: 'time'},width:'320px'},
                {title: '创建时间', align: 'center',dataIndex: 'createTime'},
                {title: '状态', align: 'center',scopedSlots: {customRender: 'isEnabled'}},
            ],
            tableData: [],
            pageNum:1,
            rowsNum:10,
            rowCount:0
      }
    },
    created(){
        this.getData()
    },
    methods: {
    //获取数据
      getData() {
            vacationList({
            storeId: this.storeId2, // 门店id
            pageNum:this.pageNum,
            rowsNum:this.rowsNum,

          })
            .then((res) => {
              this.tableData = res.items
              this.rowCount = res.rowCount
              resolve()
            })
            .finally(() => {
              // this.loading = false
            })
      },
      sizeChange(pageNum, rowsNum) { // 每页数量变化的时候
            this.pageNum = pageNum
            this.rowsNum = rowsNum
            this.getData()
        },
        
        pageChange(pageNum, rowsNum) { //
            this.pageNum = pageNum
            this.rowsNum = rowsNum
            this.getData()
        },
    },
  }
  </script>
  <style scoped lang='less'>
  </style>
  